package cn.sytton.taffe.wx.controller;

import cn.sytton.taffe.framework.base.controller.BaseController;
import cn.sytton.taffe.wx.entity.WeixinUserEntity;
import cn.sytton.taffe.wx.service.IWxAuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 微信登录控制层
 *
 * @author skyrock
 */
@Tag(name = "微信")
@RestController
@RequestMapping("/wx/auth")
public class WxAuthController extends BaseController {

    @Resource
    private IWxAuthService wxService;

    @Operation(summary = "微信登录")
    @PostMapping("/wx-code/login")
    public WeixinUserEntity loginWxCode(@RequestBody Map<String, String> body) {
        String code = body.get("code");
        return wxService.loginByWxCode(code);
    }

}
